# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=graphicsmagick

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.3.19
pkgrel=1
pkgdesc="An image viewing/manipulation program (mingw-w64)"
arch=('any')
url="http://www.graphicsmagick.org/"
license=("custom")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
    "${MINGW_PACKAGE_PREFIX}-pkg-config"
    "${MINGW_PACKAGE_PREFIX}-libxml2"
    "${MINGW_PACKAGE_PREFIX}-jasper"
    "${MINGW_PACKAGE_PREFIX}-libpng"
    "${MINGW_PACKAGE_PREFIX}-libtiff"
    "${MINGW_PACKAGE_PREFIX}-libwebp")
depends=("${MINGW_PACKAGE_PREFIX}-libtool"
    "${MINGW_PACKAGE_PREFIX}-lcms2"
    "${MINGW_PACKAGE_PREFIX}-fontconfig"
    "${MINGW_PACKAGE_PREFIX}-freetype"
    "${MINGW_PACKAGE_PREFIX}-bzip2"
    "${MINGW_PACKAGE_PREFIX}-zlib"
    "${MINGW_PACKAGE_PREFIX}-fontconfig"
    "${MINGW_PACKAGE_PREFIX}-xz"
    "${MINGW_PACKAGE_PREFIX}-glib2"
    #"${MINGW_PACKAGE_PREFIX}-perl"
    )
optdepends=("${MINGW_PACKAGE_PREFIX}-ghostscript: for Ghostscript support"
      "${MINGW_PACKAGE_PREFIX}-libxml2: for XML support"
      "${MINGW_PACKAGE_PREFIX}-jasper: for JPEG-2000 support"
      "${MINGW_PACKAGE_PREFIX}-libpng: for PNG support"
      "${MINGW_PACKAGE_PREFIX}-libtiff: for PNG support"
      "${MINGW_PACKAGE_PREFIX}-libwebp: for WEBP support")
options=('staticlibs' 'strip')
source=(http://sourceforge.net/projects/graphicsmagick/files/${_realname}/${pkgver}/GraphicsMagick-${pkgver}.tar.xz)
md5sums=('e2795d7bdc2f3917804e40c8cae1993e')

prepare() {
  cd GraphicsMagick-${pkgver}
}

build() {
  export lt_cv_deplibs_check_method='pass_all'
  cd GraphicsMagick-${pkgver}
  [[ -d ${srcdir}/build-${MINGW_CHOST} ]] && rm -rf ${srcdir}/build-${MINGW_CHOST}
  mkdir -p ${srcdir}/build-${MINGW_CHOST}
  cd ${srcdir}/build-${MINGW_CHOST}

  ../GraphicsMagick-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --enable-shared \
    --disable-static \
    --with-modules \
    --with-wmf \
    --with-xml \
    --with-lcms2 \
    --with-jp2 \
    --with-webp \
    --with-gslib \
    --without-jbig \
    --without-fpx \
    --without-dps \
    --without-perl \
    --without-x
    make  
}

package() {
  cd ${srcdir}/build-${MINGW_CHOST}
  make -j1 DESTDIR="${pkgdir}" install
}
